<?php

require_once(DIR_MODULES .'/media/media.class.php');

// Do regular task
default_controller();



$query = "SELECT M.*, R.path, R.filename as resource_filename FROM media M 
LEFT OUTER JOIN resources R ON (R.resource_id = M.resource_id)";

if($page_vars->media_category!=''){
  $criterias[] = "M.category='". $page_vars->media_category ."'";
}

if($criterias){
  $query.= " WHERE " .implode(" AND ", $criterias);  
}

$rsconn = db_query($query,true);

if($rsconn){
  $content.='<div class="media_list">';
  foreach($rsconn as $e_media){
    //$media_link = '';
    $resource = new resource($e_media['resource_id']);
    $media_link = $resource->url;
    
    $media = new media($e_media['media_id']);
    
    $thumbnail_url = $media->get_thumbnail();
    
    
    
    $content.='<div class="media_item clearfix">
      <h3>'. $e_media['title'] .'</h3>
      <div class="desc">
        <div class="thumb"><a href="'.$media_link .'" class="gallery_item" ><img src="'. $thumbnail_url .'"></a></div>
        '. $e_media['description'] . '
        <!-- <a href="'. WWW_ROOT .'inc/modules/media/controller/media_download?id='.$e_media['media_id'].'" target="_blank">'.$e_media['title'] .'</a> -->
      </div>
      </div>';
  }
  $content.='</div>';
}

$layout->add('content', $content);

/* Content Left */




?>